<%@ page pageEncoding="UTF-8"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@ taglib prefix="isperp" uri="/WEB-INF/tlds/isperp.tld"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<script type="text/javascript">
	var nodeId = "${nodeId}";
	var deployId = "${deployId}";
	var defId = "${defId}";
	var slectTextarea;
	$(function() {
		$("a[name='btnVars']").click(selectVar);
		$("#btnScript").click(selectScript);
		$("a[name='signResult']").click(function() {
			addToTextarea($(this).attr("result"));
		});
		$("a.save").click(saveCondition);
	});
	var flowVarWindow;
	//选择变量
	function selectVar() {
		FlowVarWindow({
			deployId : deployId,
			nodeId : nodeId,
			callback : function(vars) {
				addToTextarea(vars);
			}
		});
	};
	//将条件表达式追加到脚本输入框内
	function addToTextarea(str) {
		if (slectTextarea == null) {
			$.ligerMessageBox.warn('提示信息', '请先选中脚本输入框');
			return;
		}
		$.insertText(slectTextarea, str);
	};
	//textarea切换获取焦点
	function toggleFocus(e) {
		slectTextarea = e;
	};
	function selectScript() {
		ScriptDialog({
			callback : function(script) {
				addToTextarea(script);
			}
		});
	};
	function handFlowVars(obj) {
		addToTextarea($(obj).val());
	};
	function saveCondition() {
		var tasks = "";
		var conditions = "";
		$("tr.taskTr").each(function() {
			var obj = $(this);
			var condition = $("[name='condition']", obj).val();
			var task = $("input[name='task']", obj).val();
			if (condition != null && condition.trim() != "") {
				tasks += task + ",";
				conditions += condition + ",";
			}
		});
		if (conditions != "") {
			tasks = tasks.substring(0, tasks.length - 1);
			conditions = conditions.substring(0, conditions.length - 1);
		}
		var url = "workflow/processDefinition/saveCondition";

		var paras = {
			"defId" : defId,
			"nodeId" : nodeId,
			"tasks" : tasks,
			"deployId" : deployId,
			"conditions" : conditions
		};

		$.post(url, paras, function(data) {
			isperp.closeDialog();
		});
	};
</script>
<form id="bpmGatewayForm" method="post" action="#">
	<div class="header">
		<h3>${name }条件设置</h3>
	</div>
	<table class="form-table">

		<c:forEach items="${outcomeNodes}" var="outNode"
			varStatus="outNodeStatus">
			<tr class="taskTr">
				<td class="td1"><input type="hidden" name="task"
					value="${outNode.nodeId}" /> ${outNode.nodeName }</td>
				<td class="td2"><textarea name="condition" rows="3" cols="50"
						class="inputText" id="target_${outNodeStatus.index}">${outNode.condition}</textarea>

					<isperp:processVariable id="var_${outNodeStatus.index}"
						targetControlId="target_${outNodeStatus.index}" useAsScript="true"
						processKey="${defKey }"></isperp:processVariable>
				</td>
			</tr>

		</c:forEach>
	</table>

</form>



<isperp:operate>

	<div class="maincontent">
<a name="bnail"></a>
		<h3>·操作符</h3>

		<ul>
			<li><p>
					<b>1、属性操作符</b>:
					<tt>.</tt>
					和
					<tt>[]</tt>
				</p></li>
			<li><p>
					<b>2、计算操作符</b>:
					<tt>+</tt>
					,
					<tt>-</tt>
					(二元减),
					<tt>*</tt>
					,
					<tt>/</tt>
					和
					<tt>div</tt>
					,
					<tt>%</tt>
					和
					<tt>mod</tt>
					,
					<tt>-</tt>
					(一元负)
				</p></li>
			<li><p>
					<b>3、逻辑操作符</b>:
					<tt>and</tt>
					,
					<tt>&amp;&amp;</tt>
					,
					<tt>or</tt>
					,
					<tt>||</tt>
					,
					<tt>not</tt>
					,
					<tt>!</tt>
				</p></li>
			<li><p>
					<b>4、关系操作符</b>:
					<tt>==</tt>
					,
					<tt>eq</tt>
					,
					<tt>!=</tt>
					,
					<tt>ne</tt>
					,
					<tt>&lt;</tt>
					,
					<tt>lt</tt>
					,
					<tt>&gt;</tt>
					,
					<tt>gt</tt>
					,
					<tt>&lt;=</tt>
					,
					<tt>ge</tt>
					,
					<tt>&gt;=</tt>
					,
					<tt>le</tt>
					。比较操作符适用于, string, integer, 或 floating-point literals。
				</p></li>
			<li><p>
					<b>5、空值判断符</b>:
					<tt>empty</tt>
					操作符可以判断一个变量为
					<tt>null</tt>
					或者为空。

				</p></li>
			<li><p>
					<b>6、条件操作符</b>:
					<tt>A ? B : C</tt>
					。 返回
					<tt>B</tt>
					或者
					<tt>C</tt>
					, 依赖于条件
					<tt>A</tt>
					。
				</p></li>
		</ul>



	</div>
	<div class="maincontent">


		<a name="bnail"></a>
		<h3>·保留关键字</h3>
		<p>
			<a name="indexterm-262"></a>以下是EL表达式的保留关键字，请务必不要作为变量使用:
		</p>

		<table style="border:1px solid #888">
			<colgroup>
				<col width="25%">
				<col width="25%">
				<col width="25%">
				<col width="25%">
			</colgroup>
			<tbody>
				<tr>
					<td align="left" valign="top" scope="row" style="border:1px solid #888"><p>
							<tt>and</tt>
						</p></td>
					<td align="left" valign="top" scope="row" style="border:1px solid #888"><p>
							<tt>or</tt>
						</p></td>
					<td align="left" valign="top" scope="row" style="border:1px solid #888"><p>
							<tt>not</tt>
						</p></td>
					<td align="left" valign="top" scope="row" style="border:1px solid #888"><p>
							<tt>eq</tt>
						</p></td>
				</tr>
				<tr>
					<td align="left" valign="top" scope="row" style="border:1px solid #888"><p>
							<tt>ne</tt>
						</p></td>
					<td align="left" valign="top" scope="row" style="border:1px solid #888"><p>
							<tt>lt</tt>
						</p></td>
					<td align="left" valign="top" scope="row" style="border:1px solid #888"><p>
							<tt>gt</tt>
						</p></td>
					<td align="left" valign="top" scope="row" style="border:1px solid #888"><p>
							<tt>le</tt>
						</p></td>
				</tr>
				<tr>
					<td align="left" valign="top" scope="row" style="border:1px solid #888"><p>
							<tt>ge</tt>
						</p></td>
					<td align="left" valign="top" scope="row" style="border:1px solid #888"><p>
							<tt>true</tt>
						</p></td>
					<td align="left" valign="top" scope="row" style="border:1px solid #888"><p>
							<tt>false</tt>
						</p></td>
					<td align="left" valign="top" scope="row" style="border:1px solid #888"><p>
							<tt>null</tt>
						</p></td>
				</tr>
				<tr>
					<td align="left" valign="top" scope="row" style="border:1px solid #888"><p>
							<tt>instanceof</tt>
						</p></td>
					<td align="left" valign="top" scope="row" style="border:1px solid #888"><p>
							<tt>empty</tt>
						</p></td>
					<td align="left" valign="top" scope="row" style="border:1px solid #888"><p>
							<tt>div</tt>
						</p></td>
					<td align="left" valign="top" scope="row" style="border:1px solid #888"><p>
							<tt>mod</tt>
						</p></td>
				</tr>
			</tbody>
		</table>
	</div>


</isperp:operate>

<isperp:buttonList>
	<button class="submit" onclick="saveCondition()">确认</button>
</isperp:buttonList>
